package ssi.beans;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import org.apache.struts.action.ActionForm;
import org.apache.struts.upload.FormFile;

import ssi.tools.Connector;

public class Animal extends ActionForm {

	private static final long serialVersionUID = 1L;
	private String name;
	private String gender;
	private String birthDate;
	private String breed;
	private FormFile file;
	private String id;
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public FormFile getFile() {
		return file;
	}
 
	public void setFile(FormFile file) {
		this.file = file;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(String birthDate) {
		this.birthDate = birthDate;
	}

	public String getBreed() {
		return breed;
	}

	public void setBreed(String breed) {
		this.breed = breed;
	}

	public String[] getAnimal(String id){
		String[] animal=new String[6];
		try{
			Connection connection = new Connector().getConnection();
    		Statement statement = connection.createStatement();
			ResultSet result = statement.executeQuery("SELECT * from animals where id=" + id + "");
			while(result.next()){
				String name=result.getString("name");
				String gender=result.getString("gender");
				String birthDate=result.getString("birthDate");
				String breed=result.getString("breed");
				String filename=result.getString("images");
				String adopted = result.getString("adopted");
				animal[0]=name;
				animal[1]=gender;
				animal[2]=birthDate;
				animal[3]=breed;
				animal[4]=filename;
				animal[5]=adopted;
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		return animal;
	}


}
